var prefix = "/api/grade/student/subject";
var myGrid;


//显示增加对话框按钮
function showAddModel() {
    myGrid.showAddModel();
}

//显示更新对话框按钮
function showUpdateModel(id) {
    myGrid.showUpdateModel(id);
}


//查詢按钮
function searchTable() {
    myGrid.loadTable();
}

//毕业设计下拉列表
function initgrdesgin(){

    Tms.select2AjaxData("/api/grade/dimgraprj/getAll",
        "#srth_num", "thNum", "gradeName");

}



$(function () {
    var options = {
        ctrfix: "/grade/subject/student",//当前控制器
        recordId: 'id',
        tableId: '#subject_Table',
        AddDlgTitle: '新增',
        updateDlgTitle: '更新',
        recordId:'id',
        sort: 'id',
        direct: 'desc',
        listURL: function () {
            return prefix + "/getNotSelectedSubject";
        },

        columns: [
            {
                checkbox: true
            },
            {
                field: 'id',
                title: '序号',
            },
            {
                field: 'thNum',
                title: '届',
            },
            {
                field: 'subjectName',
                title: '课题',
            },
            {
                field: 'tno',
                title: '教师',
                formatter: function (data,  row,type, meta) {
                    return  row.tno+"/" + row.teacherName;
                }
            },
            {
                field: 'sno',
                title: '学生',
                formatter: function (data, row, type, meta) {
                    return  row.sno+"/" + row.studentName;
                }

            },
            {
                field: 'professionType',
                title: '专业',
            },
            {
                field: 'subjectType',
                title: '课程类型',
            },
            {
                field: 'subjectFrom',
                title: '课题来源',
            },
            {
                field: 'selectType',
                title: '选题方式',
            },
            {
                field: 'stateName',
                title: '审核状态',
            },
            {
                data : null,
                title: '查看详情',
                width: '50px',
                formatter: function (data,  row, meta) {
                    var operators = '<a type="button"  href="#" class="btn btn-mint btn-xs btn-icon" onclick=showUpdateModel(' + row.id + ',"' + options.updateDlgTitle + '") title="' + options.updateDlgTitle + '"><i class="demo-psi-pen-5 icon-lg"></i></a>';
                    return operators;
                }
            }
        ]
    }

    if (s_edit_h == '') {
        options.editable = true;
    } else {
        options.editable = false;
    }

    myGrid = new gridViewModel(options);
    myGrid.init();
    initgrdesgin();

})